#include "imageitem.h"
#include <QPainter>

static const QPointF neutralPos(0., 0.);

ImageItem::ImageItem(const QImage *image, QGraphicsItem *parentItem) :
        QGraphicsObject(parentItem),
        m_image(image)
{
}

void ImageItem::setImage(const QImage *image)
{
    m_image = image;
    QGraphicsObject::prepareGeometryChange();
    QGraphicsObject::update();
}

const QImage *ImageItem::image() const
{
    return m_image;
}

QRectF ImageItem::boundingRect() const
{
    return QRectF(neutralPos, m_image->size());
}

void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    painter->drawImage(neutralPos, *m_image);
}
